<template>
	<view class="pics">
		<scroll-view scroll-y class="left" >
			<view :class="active==index?'active':''" v-for="(item,index) in cates" :key="item.id" @click="activeHandle(index,item.id)">
				{{item.title}}
			</view>
			
			
		</scroll-view>
		<scroll-view scroll-y class="right">
			<view v-for="item in imgs" :key="item.index">
<<<<<<< HEAD
				<image @click="previewImage(item.img_url)" :src="item.img_url"></image>
=======
				<image :src="item.img_url"></image>
>>>>>>> 5354ae06e7fac328d099c8a2960335cf64b405e4
				<view>{{item.zhaiyao}}</view>
			</view>
			
		</scroll-view>		
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				active:0,
				cates:[],
				imgs:[]
			}
		},
		onLoad() {
			this.getPicsCate()
			this.activeHandle(0,14)
			
		},
		methods: {
			previewImage(current){
				console.log(current)
				const urls =  this.imgs.map(item=>{
					return item.img_url
				})
				
				uni.previewImage({
					current,
					urls
				})
			},
			async getPicsCate(){
				const res = await this.$myRequest({
					url:'/api/getimgcategory'
				})
				
				this.cates = res.data.message
			},
			async activeHandle(index,id){
				this.imgs = []
				this.active=index
				 const res = await this.$myRequest({
					url:'/api/getimages/'+id
				})
				this.imgs = res.data.message
				
			}
		}
	}
</script>

<style lang="scss">
	pageP{
		height: 100%;
	}
	.pics{
		height: 100%;
		display: flex;
		.left{
			
			width: 200rpx;
			height: 700px;
			view{
				height: 60px;
				line-height: 60px;
				text-align: center;
				color: #333;
				font-size: 30rpx;
				border: 1px solid #eee;
			}
			.active{
				background-color: #C31E00;
			}
		}
		.right{
			
			width: 530rpx;
			height: 700px;
			margin: 0 auto;
			image{
				width: 100%;
			}
		}
	}
</style>
